<!DOCTYPE html>
<html th:lang="${language}" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header(#{okr.my})" />
  <th:block th:include="include :: okr-css" />
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row" >
    <div id="ibox-content">
      <div id="vertical-timeline" class="vertical-container light-timeline" >
        <div class="vertical-timeline-block">
      </div>
    </div>
  </div>
</div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
  var prefix = ctx + "inform";
  $.ajax({
    url: prefix + "/getInformList",
    type: 'POST',
    success: function (data){
      for (let i = 0; i < data.length; i++) {
          if (data[i].type === "提醒" || data[i].type === "评论"){
              $("#vertical-timeline").append("        <div class=\"vertical-timeline-block\">\n" +
                  "          <div class=\"vertical-timeline-icon blue-bg\">\n" +
                  "            <i class=\"fa fa-at\"></i>\n" +
                  "          </div>\n" +
                  "\n" +
                  "          <div class=\"vertical-timeline-content\">\n" +
                  "            <h2>" + data[i].content + "</h2>\n" +
                  "            <p>" + data[i].parentName + "</p>\n" +
                  "            <a class=\"btn btn-sm btn-success\" onclick='confirm(" + data[i].id + ")'> 确认 </a>\n" +
                  "            <a class=\"btn btn-sm btn-info\" onclick='redirects(\"" + data[i].url + "\")'> 转跳 </a>\n" +
                  "            <span class=\"vertical-date\">\n" +
                  "                         \t通知时间 <br>\n" +
                  "                         <small>" + data[i].informTime + "</small>\n" +
                  "                     </span>\n" +
                  "          </div>\n" +
                  "        </div>")
          }else if (data[i].type === "对齐"){
              $("#vertical-timeline").append("        <div class=\"vertical-timeline-block\">\n" +
                  "          <div class=\"vertical-timeline-icon blue-bg\">\n" +
                  "            <i class=\"fa fa-hand-pointer-o\"></i>\n" +
                  "          </div>\n" +
                  "\n" +
                  "          <div class=\"vertical-timeline-content\">\n" +
                  "            <h2>" + data[i].content + "</h2>\n" +
                  "            <p>" + data[i].parentName + "</p>\n" +
                  "            <a class=\"btn btn-sm btn-success\" onclick='confirm(" + data[i].id + ")'> 确认 </a>\n" +
                  "            <a class=\"btn btn-sm btn-info\" onclick='redirects(\"" + data[i].url + "\")'> 转跳 </a>\n" +
                  "            <span class=\"vertical-date\">\n" +
                  "                         \t通知时间 <br>\n" +
                  "                         <small>" + data[i].informTime + "</small>\n" +
                  "                     </span>\n" +
                  "          </div>\n" +
                  "        </div>")
          }else if (data[i].type === "关注"){
              $("#vertical-timeline").append("        <div class=\"vertical-timeline-block\">\n" +
                  "          <div class=\"vertical-timeline-icon blue-bg\">\n" +
                  "            <i class=\"fa fa-heart\"></i>\n" +
                  "          </div>\n" +
                  "\n" +
                  "          <div class=\"vertical-timeline-content\">\n" +
                  "            <h2>" + data[i].content + "</h2>\n" +
                  "            <p>" + data[i].parentName + "</p>\n" +
                  "            <a class=\"btn btn-sm btn-success\" onclick='confirm(" + data[i].id + ")'> 确认 </a>\n" +
                  "            <a class=\"btn btn-sm btn-info\" onclick='redirects(\"" + data[i].url + "\")'> 转跳 </a>\n" +
                  "            <span class=\"vertical-date\">\n" +
                  "                         \t通知时间 <br>\n" +
                  "                         <small>" + data[i].informTime + "</small>\n" +
                  "                     </span>\n" +
                  "          </div>\n" +
                  "        </div>")
          }else if (data[i].type === "系统提醒"){
            $("#vertical-timeline").append("        <div class=\"vertical-timeline-block\">\n" +
                    "          <div class=\"vertical-timeline-icon yellow-bg\">\n" +
                    "            <i class=\"fa fa-bullhorn\"></i>\n" +
                    "          </div>\n" +
                    "\n" +
                    "          <div class=\"vertical-timeline-content\">\n" +
                    "            <h2>" + data[i].content + "</h2>\n" +
                    "            <p>" + data[i].parentName + "</p>\n" +
                    "            <a class=\"btn btn-sm btn-success\" onclick='confirm(" + data[i].id + ")'> 确认 </a>\n" +
                    "            <a class=\"btn btn-sm btn-info\" onclick='redirects(\"" + data[i].url + "\")'> 转跳 </a>\n" +
                    "            <span class=\"vertical-date\">\n" +
                    "                         \t通知时间 <br>\n" +
                    "                         <small>" + data[i].informTime + "</small>\n" +
                    "                     </span>\n" +
                    "          </div>\n" +
                    "        </div>")
          }
          else{
              $("#vertical-timeline").append("        <div class=\"vertical-timeline-block\">\n" +
                  "          <div class=\"vertical-timeline-icon blue-bg\">\n" +
                  "            <i class=\"fa fa-file-text\"></i>\n" +
                  "          </div>\n" +
                  "\n" +
                  "          <div class=\"vertical-timeline-content\">\n" +
                  "            <h2>" + data[i].content + "</h2>\n" +
                  "            <p>" + data[i].parentName + "</p>\n" +
                  "            <a class=\"btn btn-sm btn-success\" onclick='confirm(" + data[i].id + ")'> 确认 </a>\n" +
                  "            <a class=\"btn btn-sm btn-info\" onclick='redirects(\"" + data[i].url + "\")'> 转跳 </a>\n" +
                  "            <span class=\"vertical-date\">\n" +
                  "                         \t通知时间 <br>\n" +
                  "                         <small>" + data[i].informTime + "</small>\n" +
                  "                     </span>\n" +
                  "          </div>\n" +
                  "        </div>")
          }

      }
    }
  })
  function confirm(id){
      $.ajax({
          url : prefix + "/confirm",
          type : "POST",
          data : {'id' : id}
      })
      window.location.reload()
  }

  function redirects(url){
      console.log(url)
      $.modal.openTab("通知转跳", ctx + url)
  }

</script>
</body>
</html>